﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kardex_Entity;


namespace Kardex_DataAccess
{
    public class UserDA
    {
        bd_kardexEntities context;
        public UserDA()
       {
           context = new bd_kardexEntities();
       }
      
        #region User
       /// <summary>
       /// Get Object User By Password and UserName
       /// </summary>
       /// <param name="Pass">Password of the user</param>
       /// <param name="UserName">Name of User</param>
       /// <returns>Obj User</returns>
       public user GetObjUserByPass_UserName( string Pass , string UserName)
       {
           try
           {
               user UserActual;
               var query = from U in context.user
                           where U.Password == Pass && U.NameUser== UserName
                           select U;
               UserActual=query.FirstOrDefault();

               if (UserActual == null)
               {
                   return new user();
               }
               else
               {
                   return UserActual;
               }
           }
           catch (Exception ex)
           {
               throw new Exception(ex.Message.ToString());
           }
       }
        #endregion

    }
}
